package org.come.MountShouHu;

import com.tool.btn.MountShouhuBtn;
import com.tool.tcpimg.UIUtils;
import org.come.entity.Mount;
import org.come.until.SrcollPanelUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.List;

public class xuanzeJpanel extends JPanel {
    private ImageIcon xuanze=new ImageIcon("inkImg/Client/选择坐骑界面.png");
    public MountShouhuBtn queren;
    private static JList<String> listmount;
    private static DefaultListModel<String> listModel;
    private JScrollPane jScrollPane;
    public static int index;
    public static int idx;
    public xuanzeJpanel(){
        this.setPreferredSize(new Dimension(281, 342));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);
        queren=new MountShouhuBtn("inkImg/Client/60X26按钮.png",1,5,"确认",UIUtils.Black,UIUtils.TEXT_HY16,this);
        queren.setBounds(123,298,60,26);
        add(queren);
        listModel = new DefaultListModel();
        (listmount = new JList<String>(listModel) {
            {
                this.setOpaque(false);
            }
        }).setSelectionBackground(new Color(33, 42, 52));
        listmount.setSelectionMode(0);
        listmount.setBackground(UIUtils.Color_BACK);
        listmount.setCellRenderer(new MyMountRenderer());
        listmount.addMouseListener((MouseListener)new MountlistChoseMouslisten(listmount, this));
        listmount.addMouseMotionListener((MouseMotionListener)new MountlistChoseMouslisten(listmount, this));
        (this.jScrollPane = new JScrollPane((Component)listmount)).setVerticalScrollBarPolicy(22);
        this.jScrollPane.getViewport().setOpaque(false);
        this.jScrollPane.setOpaque(false);
        this.jScrollPane.setBorder(BorderFactory.createEmptyBorder());
        this.jScrollPane.setHorizontalScrollBarPolicy(31);
        this.jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
        this.jScrollPane.setBounds(10,10,250,300);
        this.add((Component)this.jScrollPane);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (xuanze!=null){
            g.drawImage(xuanze.getImage(),0,0,281,342,null);

        }
        jScrollPane.setBounds(54,60,200,230);

    }
    public void  shoumount(List<Mount>mountList){
        listModel.removeAllElements();
        for (int i=0;i<=mountList.size()-1;i++){
            listModel.addElement(mountList.get(i).getMountname());
        }

    }
    static {
        idx = -1;
    }

}
